<template>
    <div class="search-from flex justify-between">
        <el-form :inline="true" :model="searchFrom">
            <el-form-item
                label="报告名称："
                v-if="pageName != '学校总体诊改报告'"
            >
                <el-input
                    v-model.trim="searchFrom.reportName"
                    clearable
                    placeholder="报告名称"
                ></el-input>
            </el-form-item>
            <!-- <el-form-item v-if="levelType !== $config.card.WH.code" label="诊改时间：">
        <el-date-picker v-model="searchFrom.year" type="year" value-format="yyyy" placeholder="诊改时间">
        </el-date-picker>
      </el-form-item> -->
            <el-form-item
                v-if="levelType !== $config.card.WH.code"
                label="报告状态："
            >
                <!-- <el-input
                    v-model.trim="searchFrom.examineState"
                    clearable
                    placeholder="报告状态"
                ></el-input> -->
                <el-select
                    class="my-select"
                    :popper-append-to-body="false"
                    v-model="searchFrom.examineState"
                    placeholder="请选择报告状态"
                >
                    <el-option
                        v-for="item in reportStateOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item
                v-if="
                    levelType !== $config.card.WH.code &&
                        pageName == '教学单位诊改报告'
                "
                label="二级学院："
            >
                <!-- <el-input
                    v-model.trim="searchFrom.examineState"
                    clearable
                    placeholder="报告状态"
                ></el-input> -->
                <el-select
                    class="my-select"
                    :popper-append-to-body="false"
                    v-model="searchFrom.rectificationObjectName"
                    placeholder="请选择二级学院"
                >
                    <el-option
                        v-for="item in rectificationOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item
                label="编制部门："
                v-if="pageName != '学校总体诊改报告'"
            >
                <el-input
                    v-model.trim="searchFrom.preparationDepartment"
                    clearable
                    placeholder="编制部门"
                ></el-input>
            </el-form-item>
            <el-form-item label="所属诊改阶段：">
                <el-select
                    class="my-select"
                    :popper-append-to-body="false"
                    v-model="searchFrom.year"
                    @change="changeYear"
                    placeholder="请选择所属诊改阶段"
                >
                    <el-option
                        v-for="(year, i) in yearArr"
                        :key="i"
                        :label="year"
                        :value="year"
                    ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="searchData">查询</el-button>
                <!-- <el-button type="primary" @click="uploadFile" v-show="isShow == 'myReport'">上传诊改报告</el-button> -->
                <slot name="handle"></slot>
            </el-form-item>
            <el-form-item v-if="levelType === $config.card.WH.code">
                <el-button type="info" plain>重置</el-button>
                <slot name="handle"></slot>
            </el-form-item>
            <el-form-item v-if="levelType === $config.card.WH.code">
                <el-button
                    v-if="name == '线下报告维护'"
                    @click="offLineupload"
                    type="primary"
                    >上传报告</el-button
                >
                <!-- <slot name="handle"></slot> -->
            </el-form-item>
            <el-form-item v-if="levelType === $config.card.WH.code">
                <el-button @click="batchDelete" type="danger"
                    >批量删除</el-button
                >
                <slot name="handle"></slot>
            </el-form-item>
            <el-form-item v-if="levelType === $config.card.WH.code">
                <el-button type="primary"> &lt;&lt; 返回</el-button>
                <slot name="handle"></slot>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
import bus from '@/config/bus.js';
import { getAllOrganize } from '@/api/systemManage';
export default {
    name: 'MyReportSearch',
    props: {
        levelType: {
            type: [Number, String]
        },
        reportList: {
            type: Array,
            default: () => []
        }
    },
    data () {
        return {
            level: this.$config.level,
            // 报告转台组
            reportStateOptions: [
                {
                    value: 0,
                    label: '未审核'
                },
                {
                    value: 1,
                    label: '审核中'
                },
                {
                    value: 2,
                    label: '审核通过'
                },
                {
                    value: 3,
                    label: '审核不通过'
                }
            ],
            name: '', // 当前页面名
            searchFrom: {
                examineState: '',
                name: '',
                year: '', // 年度默认为当前年份
                reportName: '', // 报告名称
                rectificationObjectName: '',
                preparationDepartment: '' // 编制部门
            },
            // 责任部门
            organizeArr: [],
            yearArr: this.$config.yearArr(),
            // 当前页面名
            pageName: '',
            // 二级学院组
            rectificationOptions: []
        };
    },
    created () {
        this.name = this.$route.query.name;
        this.getOrganize();
        this.pageName = this.$route.query.name;
    },
    mounted () {},
    methods: {
        searchData () {
            this.$emit('search', this.searchFrom);
        },
        // 获取责任部门下拉数据
        getOrganize () {
            getAllOrganize()
                .then(res => {
                    this.organizeArr = res || [];
                })
                .catch();
        },
        offLineupload () {
            this.$emit('addAssert', this.$route.query.name);
        },
        batchDelete () {
            bus.$emit('batchDelete');
        },
        changeYear (val) {
            this.searchFrom.year = `${val}`;
            // console.log(typeof val, 'year');
        }
    }
};
</script>

<style lang="scss">

</style>
<style lang="scss" scoped>
.preview {
    color: #000;
}
</style>
